﻿#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "logger.h"
#include "formlog.h"
#include "widgettcpcfg.h"
#include "formpublisher.h"
#include "zmqpublisher.h"


MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    qInstallMessageHandler(Logger::CustomMessageHandler);

    initZmq();
}

//void MainWindow::initTcp()
//{
//    TcpRequester *req=new TcpRequester(this);
//    req->setName("tcp_requester");
//    FormRequester *w=new FormRequester(this);
//    w->setComm(req);
//    ui->tabWidget->addTab(w,"tcp_requester");
//}

//void MainWindow::initSerialPort()
//{
//    SerialPortRequester *req=new SerialPortRequester(this);
//    req->setName("serialport_requester");
//    FormRequester *w=new FormRequester(this);
//    w->setComm(req);
//    ui->tabWidget->addTab(w,"serialport_requester");
//}

void MainWindow::initZmq()
{
    ZmqPublisher *pub=new ZmqPublisher(this);
    pub->setName("zmq_publisher");
    FormPublisher *w=new FormPublisher(this);
    w->setComm(pub);
    ui->tabWidget->addTab(w,"zmq_publisher");
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_actionLog_triggered()
{
    static FormLog frm;
    frm.show();
}
